package com.wunong.smart.commission.service.impl;

import com.wunong.smart.commission.client.dto.CommissionDTO;
import com.wunong.smart.commission.client.query.CommissionQueryDTO;
import com.wunong.smart.commission.client.service.CommissionReadService;
import com.wunong.smart.commission.domain.repository.CommissionRepository;
import com.wunong.smart.domain.platform.rpc.Result;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static com.wunong.smart.commission.domain.converter.CommissionDomainConverter.toDto;

/**
 * @author create by zealot.zt
 */
public class CommissionReadServiceImpl implements CommissionReadService {

    @Resource
    protected CommissionRepository commissionRepository;

    @Override
    public Result<CommissionDTO> getById(Long id) {
        return Result.create(toDto(commissionRepository.getById(id)));
    }

    @Override
    public Result<List<CommissionDTO>> queryByIds(Collection<Long> ids) {
        return Result.create(toDto(commissionRepository.queryByIds(ids)));
    }

    @Override
    public Result<CommissionDTO> getById(Long userId, Long id) {
        return Result.create(toDto(commissionRepository.getById(userId, id)));
    }

    @Override
    public Result<List<CommissionDTO>> queryByBiz(String bizId, Integer bizType, Integer commissionType) {
        return Result.create(toDto(commissionRepository.queryByBiz(bizId, bizType, commissionType)));
    }

    @Override
    public Result<List<CommissionDTO>> query(CommissionQueryDTO query) {
        return Result.create(toDto(commissionRepository.query(query)));
    }

}
